package edu.sctu.practice.class01.wujiayi.assing03.practice02;

/**
 * Created by acer1 on 2015/10/24.
 */
public class ComparableCylinder extends Cylinder implements Comparable {
    public ComparableCylinder(float r, float height){
        this.r =  r;
        this.height =  height;
    }

    @Override
    public int compareTo(Object o) {
//         double c = Math.max(getArea(),((ComparableCylinder)o).getArea());
        if (getArea()>((ComparableCylinder)o).getArea()){
            return 0;
        }
        else {
            return 1;
        }
    }

    private double getArea(){
        return  r*r*Math.PI*2+r*2*Math.PI*height;
    }
}
